<!doctype html>
<html class="no-js">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>{$system_name}</title>
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">
    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <!-- Tile icon for Win8 (144x144 + tile color) -->
    <meta name="msapplication-TileColor" content="#0e90d2">
    <!-- SEO: If your mobile URL is different from the desktop URL, add a canonical link to the desktop page https://developers.google.com/webmasters/smartphone-sites/feature-phones -->
    <!--
  <link rel="canonical" href="http://www.example.com/">
  -->
    <link rel="stylesheet" href="__PUBLIC__/assets/css/amazeui.min.css">
    <link rel="stylesheet" href="__PUBLIC__/assets/css/app.css">
    <!--<link rel="stylesheet" href="__PUBLIC__/assets/css/index.css">-->
    <!--必要样式-->
    <style>

        @font-face {
            font-family: fzhtjt;
            src: url("__PUBLIC__/assets/fonts/fzhtjt.TTF");
        }

        .wrap {
            padding: 10px;
            width: 100%;
        }

        .wrap-left {
            padding: 0px;
            height: 177px;
            border: 1px solid #BFBFBF;
            position: relative;
        }

        .wrap-left .username {
            display: inline-block;
            width: 100%;
            padding: 0 5px;
            color: #333;
            overflow: hidden;
            text-overflow: ellipsis;
            -o-text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 14px;
            vertical-align: bottom;
        }

        .wrap-left .map {
            vertical-align: middle;
            font-size: 9px;
            display: inline-block;

        }

        .wrap-state {
            margin-top: 5px;
            line-height: 24px;
            display: block;
            width: 100%;
            background: #E3E3E3;
            color: #333;
        }

        .wrap-state-change {
            position: absolute;
            bottom: 0;
            background: #F6DB7F;
        }

        .wrap-center {
            height: 177px;

            padding: 0 10px;
        }

        .wrap-info {
            height: 100%;
            border: 1px solid #BFBFBF;
            padding: 10px 0;
        }

        .wrap-info .other {
            color: #666666;
            display: block;
            font-size: 10px;
            line-height: 21px;
        }

        .xuanyan {
            font-size: 11px;
            color: #666;
            padding: 5px 10px 5px;
            border-bottom: 1px solid #A0A0A0;
        }

        .room-set {
            position: absolute;
            z-index: 180;
            width: 108px;
            background: #434343;
            right: 5px;
            top: 55px;
            display: none;
        }

        .room-set-item {
            width: 100%;
            padding: 0 0 9px 9px;
            height: 30px;
            line-height: 30px;
        }

        .room-set-item span {
            color: #FFF;
            vertical-align: middle;
            font-size: 14px;
            margin-left: 5px;
        }

        .time {
            display: block;
            font-family: 'fzhtjt';
            font-size: 16px;
            color: #251D02;
            line-height: 30px;
        }

        #right {
            display: none;
        }

        .file {
            position: absolute;
            display: inline-block;
            background: #FFF;
            border: 1px solid #359306;
            border-radius: 4px;
            /*padding: 4px 12px;*/
            width: 110px;
            text-align: center;
            font-size: 12px;
            overflow: hidden;
            color: #359306;
            text-decoration: none;
            text-indent: 0;
            line-height: 21px;
            /*top: 6px;*/
            left: 20%;
        }

        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }

        .file:hover {
            /*background: #AADFFD;*/
            /*border-color: #78C3F3;*/
            color: #359306;
            text-decoration: none;
        }

        .caozuo {
            padding: 8px 0;
            border-bottom: 1px solid #A0A0A0;
            position: relative;
            display: none;
        }

        #contact_code{
            float: right;
            margin-right: 20%;
        }
        .contact {

            color: #EF8514;
            border: 1px solid #EF8514;
            border-radius: 5px;
            font-size: 12px;
            width: 68px;
            display: inline-block;
            text-align: center;
            line-height: 21px;

        }

        .other-info {
            padding: 10px 20px 10px 10%;
            border-bottom: 1px solid #A0A0A0;
            display: none;
        }

        .other-info .other-info-item {
            display: block;
            color: #333;
            font-size: 13px;
        }

        .copy {
            display: inline-block;
            float: right;
            font-size: 10px;
            color: #666;
            border: 1px solid #666;
            width: 48px;
            text-align: center;
            line-height: 15px;
            border-radius: 3px;
            z-index: 999;
        }

        .tip {
            display: none;
        }
    </style>
</head>
<input type="hidden" id="money_type" value="{$room.money_type}">
<input type="hidden" id="password_hidden" value="{$room.password}">
<!-- 微信自定义接口 -->
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
    wx.config({
        "debug": false,
        "beta": false,
        'appId': '{$appId}',
        'timestamp':'{$timestamp}',
        'nonceStr': '{$noncestr}',
        'signature': '{$signature}',
        "jsApiList": ["onMenuShareAppMessage", "onMenuShareTimeline"]
    });
    wx.ready(function () {
        wx.onMenuShareAppMessage({
            title: '我在{$system_name}摆了一个王者荣耀擂台 欢迎来战！赢取千元大礼！',
            desc: '我在{$system_name}摆了一个王者荣耀擂台 欢迎来战！赢取千元大礼！',
            link: "{$host}/Home/WeChat/loginRoom?user_id={$user_id}&type=room&room_id={$room.id}&password={$password}",
            imgUrl: '{$host}__PUBLIC__/images/wechat_share.jpg'
        });
        wx.onMenuShareTimeline({
            title: '我在{$system_name}摆了一个王者荣耀擂台 欢迎来战！赢取千元大礼！',
            desc: '我在{$system_name}摆了一个王者荣耀擂台 欢迎来战！赢取千元大礼！',
            link: "{$host}/Home/WeChat/loginRoom?user_id={$user_id}&type=room&room_id={$room.id}&password={$password}",
            imgUrl: '{$host}__PUBLIC__/images/wechat_share.jpg'
        });
    });
    function weChat(){
        $("#mcover").css("display","none");  // 点击弹出层，弹出层消失
    }
</script>
<!-- 微信自定义接口 -->
<body>
<header data-am-widget="header" class="am-header am-header-default" style="position: relative">
    <include file="Public:nav_left" />

    <h1 class="am-header-title">
        <a href="#title-link" class="">
            擂台号:{$room.id}
        </a>
    </h1>

    <!--打擂中，隐藏改按钮-->
    <if condition="($user_id eq $room['user_id']) AND ($room['status'] eq 0)">
        <div class="am-header-right am-header-nav">
            <a href="#right-link" class="">
                <i class="am-header-icon am-icon-cog" style="font-size: 180%" onclick="setting()"></i>
            </a>
        </div>
        <div class="room-set">
            <a href="#">
                <div class="room-set-item" onclick="showPasswordModal()">
                    <img src="__PUBLIC__/assets/i/edit.png" width="18" alt=""> <span>修改密码</span>
                </div>
            </a>
            <a href="#">
                <div class="room-set-item" onclick="dissolutionRoom()">
                    <img src="__PUBLIC__/assets/i/out.png" width="20" alt=""> <span style="margin-left: 3px">解散房间</span>
                </div>
            </a>
            <a href="#">
                <div class="room-set-item" onclick="shareLink()">
                    <img src="__PUBLIC__/assets/i/share.png" width="18" alt=""> <span style="margin-left: 3px">分享链接</span>
                </div>
            </a>
            <!--<a href="#">-->
            <!--<div class="room-set-item">-->
            <!--<img src="__PUBLIC__/assets/i/share.png" width="18" alt=""> <span>分享朋友</span>-->
            <!--</div>-->
            <!--</a>-->
        </div>
    </if>
</header>
<div class="am-g">
    <div class="am-u-sm-12 am-padding-0">
        <img src="__PUBLIC__/images/banner.jpg" width="100%" height="185" alt="">
    </div>
</div>


<div class="wrap am-g">
    <div class="am-u-sm-4 am-text-center wrap-left">

        <img src="{$room.head_url}" width="75" height="75" class="am-round" alt="" style="margin-top: 10px"><br>
        <eq name="room.user_sex" value="0">
            <img src="__PUBLIC__/assets/i/boy.png" width="20" alt="">
            <else/><img src="__PUBLIC__/assets/i/girl.png" width="20" alt="">
        </eq>
        <span class="username">{$room.user_nickname}</span>
        <img src="__PUBLIC__/assets/i/map_sm.png" alt="" width="10"><span class="map">{$room.region_name}</span>
        <span class="wrap-state room-status"><switch name="room.status">
                                <case value="0">等待打擂中...</case>
                                <case value="1">正在打擂中...</case>
                                <case value="2">已经结束</case>
                                <case value="3">已经解散</case>
                            </switch></span>
    </div>
    <div class="am-u-sm-4 wrap-center">
        <div class="wrap-info am-text-center">
            <span class="time">
                <span id="minute_show">{$minTimeStr}:</span>
                <span id="second_show">{$secTimeStr}</span>
            </span>
            <img src="__PUBLIC__/assets/i/vs001.png" width="30" alt="" style="margin: 5px">
            <span class="other state room-status"><switch name="room.status">
                                <case value="0">等待打擂中...</case>
                                <case value="1">正在打擂中...</case>
                                <case value="2">已经结束</case>
                                <case value="3">已经解散</case>
                            </switch></span>
            <span class="other">
                <!--coin是金币-->
                <eq name="room.money_type" value="0">
                    <img src="__PUBLIC__/assets/i/coin.png"
                         style="display: inline-block;margin-top: -3px" width="14" alt="">
                    <else/><img src="__PUBLIC__/assets/i/diamond.png"
                                style="display: inline-block;margin-top: -3px" width="14" alt="">
                </eq>
                 {$room.integral}</span>
            <span class="other">战区:<switch name="room.region">
                                <case value="0"><img src="__PUBLIC__/assets/i/add/qq2.png" width="12" alt=""><span style="vertical-align: middle;display: inline-block">QQ区</span></case>
                                <case value="1"><img src="__PUBLIC__/assets/i/add/wx2.png" width="12" alt=""><span style="vertical-align: middle;display: inline-block">微信区</span></case>
                            </switch></span>
            <span class="other">模式:
                                <switch name="room.model">
                    <case value="0">
                        1v1 墨家
                    </case>
                    <case value="1">
                        3V3 长平
                    </case>
                    <case value="2">
                        5V5 深渊
                    </case>
                    <case value="3">
                        5V5 王者
                    </case>
                    <case value="4">
                        5V5 征召
                    </case>
                    <case value="5">
                        输赢排位赛
                    </case>
                    <case value="6">
                        排位输赢「大」
                    </case>
                    <case value="7">
                        排位输赢「小」
                    </case>
                    <case value="8">
                        排位输赢「单」
                    </case>
                    <case value="9">
                        排位输赢「双」
                    </case>

                </switch></span>
            <span class="other">手机系统:<switch name="room.systems_name">
                                <case value="0"><img src="__PUBLIC__/assets/i/add/az2.png" width="12" alt=""><span style="vertical-align: middle;display: inline-block">安卓</span></case>
                                <case value="1"><img src="__PUBLIC__/assets/i/add/pg2.png" width="12" alt=""><span style="vertical-align: middle;display: inline-block">苹果</span></case>
                            </switch></span>
        </div>
    </div>
    <a href="javascript:void(0);" onclick="goRing()" id="onring">
        <div class="am-u-sm-4 am-text-center wrap-left">
            <img src="__PUBLIC__/assets/i/wait.png" width="75" height="75" class="am-round" alt="" style="margin-top: 10px"><br>
            <span class="wrap-state wrap-state-change">我要打擂</span>
        </div>
    </a>
    <div class="am-u-sm-4 am-text-center wrap-left" id="right">
        <img src="{$room.o_head_url}" id="opponent_head_url" width="75" height="75" class="am-round" alt="" style="margin-top: 10px"><br>
        <eq name="room.opponent_sex" value="0">
            <img src="__PUBLIC__/assets/i/boy.png" id="opponent_sex"  width="20" alt="">
            <else/><img src="__PUBLIC__/assets/i/girl.png" id="opponent_sex" width="20" alt="">
        </eq>
        <span class="username" id="opponent_nickname">{$room.opponent_nickname}</span>
        <img src="__PUBLIC__/assets/i/map_sm.png" alt="" width="10"><span id="ou_region_name" class="map">{$room.o_region_name}</span>
        <span class="wrap-state room-status"><switch name="room.status">
                                <case value="0">等待打擂中...</case>
                                <case value="1">正在打擂中...</case>
                                <case value="2">已经结束</case>
                                <case value="3">已经解散</case>
                            </switch></span>
    </div>

    <div class="am-u-sm-12 xuanyan">
        擂台宣言：{$room.declaration}
    </div>
    <div class="am-u-sm-12 caozuo am-text-center" id="game_info">
        <a href="javascript:void(0);" class="file">胜方上传比赛结果
            <form id="upload_form">
                <input type="hidden" name="user_id" value="{$user_id}">
                <input type="hidden" name="room_id" value="{$room.id}">
                <input type="file" name="file" id="file">
            </form>
        </a>
        <div id="contact_code" style="display: inline-block">
            <a href="__URL__/contactCode"><span class="contact">联系裁判</span></a>
        </div>
    </div>

    <div class="am-u-sm-12 other-info" id="opponent_info">
        <span class="other-info-item " id="game_start" style="display: block;text-align: center;color: #F00;font-size: 16px;line-height: 30px;">匹配成功请您尽快开始游戏！</span>

    </div>
    <div class="am-u-sm-12 tip" id="hint_info">
        <span style="font-size: 9px;color: red;">温馨提示：<br/>1.长按屏幕选择复制对手信息<br/> 2.若联系不上对手请在5分钟内联系裁判</span>
    </div>
    <div class="am-u-sm-12 xuanyan guize">
        擂台规则：{$content}
    </div>

</div>


<div class="am-modal am-modal-confirm" tabindex="-1" id="money_confirm">
    <div class="am-modal-dialog">
        <div class="am-modal-bd" style="color: #251D02;" id="money_content">
            对不起，您的钻石不足！
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" style="color: #333" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>充值</span>
        </div>
    </div>
</div>

<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
    <div class="am-modal-dialog">
        <div class="am-modal-bd" id="recharge_content">
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn am-model-yes" id="confirm_btn" style="color: #0096FF;" data-am-modal-confirm>充值</span>
        </div>
    </div>
</div>

<div class="am-modal am-modal-confirm" tabindex="-1" id="password_modal">
    <div class="am-modal-dialog">
        <div class="am-modal-hd" >修改密码
            <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a></div>
        <div class="am-modal-bd" id="upload">
            <div class="am-g" id="roomPassword">
                <div class="am-u-sm-4 am-padding-0 am-text-right info-wrap-item">
                    <span class="title" style="font-size: 14px;">原密码</span>
                </div>
                <div class="am-u-sm-8 am-padding-0">
                    <input type="password" id="password" placeholder="请输入原密码" style="width: 108px;font-size: 12px;">
                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-4 am-padding-0 am-text-right info-wrap-item">
                    <span class="title" style="font-size: 14px;">新密码</span>
                </div>
                <div class="am-u-sm-8 am-padding-0" >
                    <input type="password" id="new_password" placeholder="请输入新密码" style="width: 108px;font-size: 12px;">
                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-4 am-padding-0 am-text-right info-wrap-item">
                    <span class="title" style="font-size: 14px;">确认密码</span>
                </div>
                <div class="am-u-sm-8 am-padding-0" >
                    <input type="password" id="confirm_password" placeholder="请输入确认密码" style="width: 108px;font-size: 12px;">
                </div>
            </div>
            <!--<label>原密码</label>-->
            <!--<input type="text" class="am-form-field" placeholder="" name="password" id="password">-->
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn am-model-yes" onclick="modifyPassword()" style="color: #0096FF;" data-am-modal-confirm>设置</span>
        </div>
    </div>
</div>

<!--<div class="am-modal am-modal-prompt" tabindex="-1" id="disbanded_modal">-->
    <!--<div class="am-modal-dialog">-->
        <!--<div class="am-modal-hd">提交申请-->
            <!--<a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a></div>-->
        <!--<div class="am-modal-bd">-->
            <!--<div class="am-g">-->
                <!--<div class="am-modal-bd">-->
                    <!--<textarea  name="user_remark" id="user_remark" class="am-modal-prompt-input" placeholder="请填写解散原因"></textarea>-->
                <!--</div>-->
            <!--</div>-->
            <!--&lt;!&ndash;<label>原密码</label>&ndash;&gt;-->
            <!--&lt;!&ndash;<input type="text" class="am-form-field" placeholder="" name="password" id="password">&ndash;&gt;-->
        <!--</div>-->
        <!--<div class="am-modal-footer">-->
            <!--<span class="am-modal-btn" data-am-modal-cancel>取消</span>-->
            <!--<span class="am-modal-btn am-model-yes" onclick="disbanded()" style="color: #0096FF;" data-am-modal-confirm>提交</span>-->
        <!--</div>-->
    <!--</div>-->
<!--</div>-->
<style>
    .share{
        position: fixed;width: 100%;height: 100%;background:rgba(0,0,0,0.7);z-index: 9999;top: 0;display: none;
    }
</style>
<div class="share" onclick="closeShare()">
    <img src="__PUBLIC__/images/guide.png" alt="" style="position: absolute;top: 0;right: 0">
</div>
<!--[if (gte IE 9)|!(IE)]><!-->
<script src="__PUBLIC__/assets/js/jquery.min.js"></script>
<script src="__PUBLIC__/assets/js/angular.min.js"></script>
<script src="__PUBLIC__/assets/js/amazeui.min.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
<!--剪切板插件-->
<script src="__PUBLIC__/assets/js/zlicp/jquery.zclip.js"></script>
<script type="text/javascript">
    $(window).load(function () {
       var is_show_info = '{$show_info}';
       if(is_show_info == 1){
           show_info();
       }
    });
    //倒计时
    var intDiff = parseInt(300);//倒计时总秒数量
    $(function () {
        var time = '{$time}';
        if(time < 300 && time>0){
            intDiff = parseInt(time);
            timer(intDiff);
        }
    });
    function goRing() {
        //积分不足时
//        if (true) {
//            $('.am-modal-bd').html('积分余额不足');
//            $('.am-model-yes').html('充值');
//        }
        //积分够时
        var money_type = '{$room.money_type}';
        console.info(money_type);
        var money = '钻石';
        if(money_type == 0){
            money = '金币';
        }
        $('#recharge_content').html('本次挑战需要{$room.integral}'+money+' <br>点击确认进入挑战');
        $('#confirm_btn').html('确定');
        $('#my-confirm').modal({
            relatedTarget: this,
            // 确定
            onConfirm: function (options) {
                challenge();
                //隐藏打擂
//                $('#onring').hide();
//                //显示打擂者信息
//                $('#right').show();
//                $('.wrap-state').html('游戏进行中');
//                $('.state').html('进行中');
//                //隐藏房间设置功能
//                $('.am-header-right').hide();
//                $('.guize').hide();
//                $('.caozuo').show();
//                $('.other-info').show();
//                $('.tip').show();

            },
            // 取消
            onCancel: function () {
            }
        });
    }
    function show_info(){
        layer.msg('温馨提示：请加对方微信或游戏好友进行约战<br>胜利方请第一时间上传比赛截图', {
            time: 20000, //20s后自动关闭
            btn: ['确定'],
            btnAlign:'c'
        },function () {

        });
    }
    //挑战
    function challenge(){
        var id = '{$room.id}';
        $.ajax({
            url:"__APP__/Home/Room/challenge",
            type:"post",
            dataType: "json",
            data:{room_id:id},
            success: function(data){
                console.info(data);
                if(data.code != 1)
                    layer.msg(data.message);
                if(data.success){
                    showInfo(data.data);
//                    change();
                    timer(intDiff);
                    show_info();
                }else{
                    if(data.code == 1){
                        //钻石不足
                        layer.confirm(data.message, {
                            btn: ['充值','取消'] //按钮
                        }, function(){
                            window.location.href='__APP__/Home/Recharge/';
                        }, function(){

                        });
                    }
                }
            },
            error:function (data) {
                layer.msg('服务器繁忙！',{type:1,time:1000},function(){
//                        location.reload();
                });
            }
        });
    }
    //显示挑战者信息
    function showInfo(data){
        //房主信息
//        $('#copy_text1').empty().html('对方玩家微信号:'+data.roomUser.wechat_number);
//        $('#copy_text2').empty().html('对方玩家游戏号:'+data.roomUser.game_name);
//        $('#copy_text3').empty().html('对方玩家QQ号:'+data.roomUser.qq_number);
//        var region = '微信区';
//        if(data.roomUser.region == 0){
//            region = 'QQ区';
//        }
//        $('#o_region').empty().html('对方玩家游戏战区:'+region);
//        var systems_name = '苹果';
//        if(data.roomUser.systems_name == 0){
//            systems_name = '安卓';
//        }
//        $('#o_systems_name').empty().html('对方玩家手机系统:'+systems_name);

        //挑战者信息
        $('.room-status').empty().html('正在打擂中...');
        if(data.opponentUser.sex == 0){
            $('#opponent_sex').attr('src','__PUBLIC__/assets/i/boy.png');
        }else{
            $('#opponent_sex').attr('src','__PUBLIC__/assets/i/girl.png');
        }
        $('#opponent_head_url').attr('src',data.opponentUser.head_url);
        $('#opponent_nickname').empty().html(data.opponentUser.nickname);
        $('#ou_region_name').empty().html(data.opponentUser.region_name);

        challenger_show();//显示挑战者信息
        opponent_show();//显示对手信息
    }
    //隐藏挑战者信息
    function opponent_hint(){
        $('#right').hide();
        $('#onring').show();
        $('#opponent_info').hide();
        $('#game_info').hide();
        $('#hint_info').hide();
    }
    //显示挑战者信息
    function challenger_show(){

        $('#hint_info').show();
        $('#right').show();
        $('#onring').hide();
    }
    //显示对手信息
    function opponent_show(){
        $('#opponent_info').show();
        $('#game_info').show();
    }
    $(function () {
        var opponent_id = '{$room.opponent_id}';
        var user_id = '{$user_id}';
        var room_user_id = '{$room.user_id}';
        if(opponent_id !=''){
            challenger_show();
            if(room_user_id == user_id || opponent_id == user_id){
                opponent_show();//显示对手信息
            }
        }else{
            opponent_hint();
        }
        var roomPassword = '{$room.password}';
        if(roomPassword !=''){
            $('#roomPassword').show();
        }else{
            $('#roomPassword').hide();
        }
    });
    function setting() {
        $('.room-set').slideToggle();
    }



    function dissolutionRoom() {
        var id = '{$room.id}';
        layer.prompt({title: '请填写解散原因',value: ' ', formType: 2}, function(remark, index){

            layer.close(index);
            $.ajax({
                url:"__APP__/Home/Room/disbanded",
                type:"post",
                dataType: "json",
                data:{
                    user_remark:remark,
                    room_id:id
                },
                success: function(data){
                    layer.msg(data.message);
                    if(data.success){
                        $('#password_hidden').val('111');
                        $('#roomPassword').show();
                        window.location.href = '__APP__/Home/Room/';
                    }
                },
                error:function (data) {
                    layer.msg('服务器繁忙！',{type:1,time:1000},function(){
//                        location.reload();
                    });
                }
            });
        });
    }

    function modifyPassword(){
        var roomPassword = $('#password_hidden').val();
        var password = '';
        if(roomPassword != ''){
            password = $('#password').val();
            if(password == ''){
                layer.msg('请输入原始密码！');
                return;
            }
        }
        var new_password = $('#new_password').val();
        var confirm_password = $('#confirm_password').val();
        if(new_password == ''){
            layer.msg('请输入原始密码！');
            return;
        }
        if (new_password.length < 6 || new_password.length > 18) {
            layer.msg('新密码必须是6~18位！');
            return;
        }
        if(new_password != confirm_password){
            layer.msg('密码不一致！');
            return;
        }
        var id = '{$room.id}';
        $.ajax({
            url:"__APP__/Home/Room/modifyPassword",
            type:"post",
            dataType: "json",
            data:{
                password:password,
                new_password:new_password,
                confirm_password:confirm_password,
                room_id:id
            },
            success: function(data){
                layer.msg(data.message);
                if(data.success){
                    $('#password_hidden').val('111');
                    $('#roomPassword').show();
                }
            },
            error:function (data) {
                layer.msg('服务器繁忙！',{type:1,time:1000},function(){
//                        location.reload();
                });
            }
        });
    }

    $("#file").change( function(){
        uploadImage();
        $('#file').replaceWith('<input name="file" type="file" id="file"  />');
        console.info('change');
    });

    function uploadImage(){
        var formData = new FormData(document.getElementById('upload_form'));
        console.info(formData);
        var index = layer.load(2);
        $.ajax({
            url:"__APP__/Home/Room/publishResult",
            type:"post",
//            data:$('#comment_form').serialize(),
            data:formData,
            dataType: "json",
            processData: false,
            contentType: false,
            success: function(data){
                layer.close(index);
                console.info(data);
                layer.msg(data.message);
            },
            error:function (data) {
                layer.msg('服务器繁忙！');
//                modalInfo('服务器繁忙！',false);
            }
        });
    }

    function changePsw() {
        layer.prompt({title: '请输入原密码', formType: 1}, function (pass, index) {
            if (pass == '1') {
                layer.close(index);
                layer.prompt({title: '请输入新密码', formType: 1}, function (text, index) {
                    if (text.length < 6 || text.length > 18) {
                        layer.msg('新密码必须是6~18位！');
                    } else {
                        layer.close(index);
                    }
//                    layer.msg('演示完毕！您的口令：'+ pass +'<br>您最后写下了：'+text);
                });
            } else {
                layer.msg('原密码输入有误');
            }
        });
    }




    function timer(intDiff) {
        window.setInterval(function () {
            var
                    day = 0;
            hour = 0;
            minute = 0,
                    second = 0;//时间默认值
            if (intDiff > 0) {
                day = Math.floor(intDiff / (60 * 60 * 24));
                hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
                minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
                second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
            }
            if (minute <= 9) minute = '0' + minute;
            if (second <= 9) second = '0' + second;
            $('#day_show').html(day + "天");
            $('#hour_show').html('<s id="h"></s>' + hour + '时');
            $('#minute_show').html('<s></s>' + minute + ':');
            $('#second_show').html('<s></s>' + second + '');
            intDiff--;
            if(intDiff == 0){
                $('#contactCode').hide();
            }
        }, 1000);
    }

    function showPasswordModal(){
        $('#password').val('');
        $('#new_password').val('');
        $('#confirm_password').val('');
        $('#password_modal').modal();
    }

    //复制
    $(function () {


    })
//    function change() {
//
//        $('#copy1').zclip({
//            path: 'assets/js/zlicp/ZeroClipboard.swf',
//            copy: function () {//复制内容
//                return $('#copy_text1').val();
//
//            },
//            afterCopy: function () {//复制成功
//                layer.msg('微信号复制成功')
////                $("<span id='msg'/>").insertAfter($('#copy1')).text('复制成功');
//            }
//        });
//        $('#copy2').zclip({
//            path: 'assets/js/zlicp/ZeroClipboard.swf',
//            copy: function () {//复制内容
//                return $('#copy_text2').val();
//
//            },
//            afterCopy: function () {//复制成功
//                layer.msg('游戏号复制成功')
////                $("<span id='msg'/>").insertAfter($('#copy1')).text('复制成功');
//            }
//        });
//    }

    function shareLink(){
        $('.share').show();
        $('.room-set').slideToggle();
    }
    function closeShare(){
        $('.share').hide();
    }
</script>
</body>
</html>

